home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / ISR.SWG / 0001_CLOCK.PAS.pas next >
Pascal/Delphi Source File  |  1993-05-28  |  3KB  |  64 lines

  1. {$M 2000, 0, 0}                         {  When writing TSR's you have to   }
  2. Program Clock;                          {  use the $M directive             }
  3. Uses Dos;
  4.  
  5.  Var
  6.    oldint: Procedure;
  7.  
  8. Procedure Write2scr (s: String; color, x, y: Byte);
  9.  Var
  10.    counter1,
  11.    counter2: Byte;
  12.  begin                                             { In TSR's you always }
  13.     counter1 := 2 * (x + y * 80);                  { need to use direct  }
  14.     For counter2 := 1 to ord(s[0]) do              { screen Writes.      }
  15.      begin                                         {                     }
  16.       mem [$b800: counter1] := ord(s[counter2]);
  17.       inc (counter1);
  18.       mem [$b800: counter1] := color;
  19.       inc (counter1);
  20.      end;  {do}
  21.  
  22.  end;      {Write2SCR}
  23.  
  24. {$F+}                   { All Procedures will now be Far Procedures }
  25.  
  26. Procedure int_Hook; interrupt;
  27. Var
  28.    hour,                { Where the Hour will be stored }
  29.    min: Word;           { "  "  " " minute "          " }
  30.    hS,                  { Where STR Hour will be stored }
  31.    MS: String[2];       {       STR Min                 }
  32. begin
  33.      hour := memW[$0000:$046e];
  34.      min := (memW[$0000:$046c] div 18) div 60;
  35.  
  36. { The above 2 lines of code give the hour & minute.. How?? The first
  37.   memory location gives the hour thats easy, but the minutes are a
  38.   little more tricky... The interrupt i'm gonna hook into is int 8
  39.   ... it is called approximately 18.2 times/second. When its called,
  40.   it increments 0000:046c hex. When it overflows, it inc's 0000:046e
  41.   (which is the hour in 24 hr Format) so, dividing by 18 would give
  42.   us the approximate second in the hour, div'ding by 60 then gives
  43.   the hour                                                              }
  44.  
  45.      if hour > 12 then dec(hour, 12);           { Converts from 24 hr Format }
  46.      str(min, MS);
  47.      str(hour, HS);
  48.      Write2scr (HS, 9, 77 - ord(hs[0]), 0);     { Writes to screen }
  49.      Write2scr (MS, 12, 78, 0);
  50.      Write2scr (':',10, 77, 0);
  51.      Inline ($9c);                              { Push the flags ( you have }
  52.      oldint;                                    { to do this beFore any int }
  53.                                                 { call like this            }
  54. end;   {inT_HOOK}
  55.  
  56. {$F-}                                           { No more Far Procedures }
  57.  
  58. begin
  59.   getintvec (8, @oldint);                       { Hooks the interrupt }
  60.   setintvec (8, addr(int_hook));
  61.   keep (0);                                     { Makes it stay resident }
  62. end.
  63.  
  64.